package com.jeespring.rocketmq.simple.oneway;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;

/**
 * @description Producer
 * @author 张朝阳
 * @date 2021/9/14 23:36:32
 */
public class Producer {
    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("producer-group");

        producer.setNamesrvAddr("192.168.19.10:9876");
        producer.start();

        for (int i = 0; i < 10; i++) {
            //public Message(String topic, String tags, byte[] body)
            String msg = "单向消息" + i;
            Message message = new Message("simple-message","oneway",msg.getBytes(RemotingHelper.DEFAULT_CHARSET));

            producer.sendOneway(message);
        }

    }
}
